/*
 * @Description: 
 * @Author: liuzl
 * @Date: 2024-09-24 15:19:08
 * @LastEditors: liuzl
 * @LastEditTime: 2024-09-24 16:00:43
 */
/**
 * Student
 */
public class Student {

    //属性
    private String name;
    private int age;
    public Student(){}
    public Student(String name,int age){
        this.name = name;
        this.age = age;
    }
    public void setName(String name){

    }
    public String getName(){
        return name;
    }
    public void setAge(int age){

    }
    public int getAge(){
        return age;
    }
    @Override
    public boolean equals(Object obj) {
        System.out.println("重写equals方法");
        //重写equals方法
        boolean result = false;
        //类型判断
        //instanceof用于检查对象是否是Student类型的实例；返回值是boolean类型
        //第一步，判断类型是否相同
        //如果类型不同 那么直接返回false
        if(!(obj instanceof Student)){
            //result = true;
            return false;
        }
        //第二步判断 判断值是否相同
        //向下转型 强转
        Student s = (Student) obj;
        if(name.equals(s.getName())&& age==s.getAge()){
            result = true;
        }
        return result;
    }
}